﻿<!DOCTYPE html>
<html>
<head>
  <title>修改文档</title>
  <!--
  $css()$js()
    <script type="text/javascript" src="/framework/common/editor/minpack.js"></script>
    <script type="text/javascript" src="/framework/common/editor/plugins/code/prettify.js"></script>
  -->
</head>
<body>

<style type="text/css">
    /*.archive_edit{width:680px;margin-right:-700px;float:left;margin-left:20px;}
    
    
    .extinfo{width:auto;float:left;margin-left:700px;}
    .extinfo p{position:relative;}
    .extinfo .pro_upload{}
    .extinfo .pro_upload .uploadinfo{}
    */
    
    dl dt{float:left;}
    .submitbar{padding:10px 0 30px 60px;}
</style>


<form method="post" action="" enctype="application/x-www-form-urlencoded">
<div class="tabarea">
    <div class="tab_mini">
        <a href="javascript:;" class="current">修改文档</a>
    </div>
        <div class="area">
    <div class="archive_edit">

    
      

        <input type="hidden" name="archive.id" value="${archiveID}" />

       <!--
        <div class="line ui-category-selector">
        <span class="txt"><span class="star">*</span>栏目:</span>
            <div class="result">一请选择栏目一</div>
            <input type="text" name="categoryid" disabled="disabled" class=" ui-validate textbox" required="true" summary="{required:'请选择栏目'}"/> 
            <div class="list">
                ${categoriesHtml}
            </div>
        </div>
        
        <script type="text/javascript">
            var selectors = document.getElementsByClassName('ui-category-selector');
            for (var i = 0; i < selectors.length; i++) {
                var resultDiv = selectors[i].getElementsByTagName('DIV')[0];
                var listDiv = selectors[i].getElementsByTagName('DIV')[1];
                var resultIput = selectors[i].getElementsByTagName('INPUT')[0];


                resultDiv.onclick = resultIput.onfocus = (function (_listDiv, _iput) {
                    return function () {
                        _listDiv.style.display = 'block';
                        _listDiv.style.width = _iput.offsetWidth + 'px';

                        //隐藏高度
                        if (_listDiv.offsetHeight > 400) {
                            _listDiv.style.height = '400px';
                        }
                    };
                })(listDiv, resultIput);
                var _links = listDiv.getElementsByTagName('A');
                for (var j = 0; j < _links.length; j++) {
                    _links[j].onclick = (function (rd, ld, ri, cid, cname) {
                        return function () {
                            ld.style.display = 'none';
                            rd.innerHTML = cname;
                            ri.value = cid;
                        };
                    })(resultDiv, listDiv, resultIput, _links[j].getAttribute('val'), _links[j].getAttribute('txt'));
                }
            }
        </script>
        -->

        <dl>
            <dt><span class="star">*</span>栏目：</dt>
            <dd>
                <select name="categoryid" requred="true" summary="{required:'请选择栏目!'}">
                    <option>一请选择栏目一</option>
                    ${nodes}
                </select>
            </dd>
        </dl>

        <dl>
            <dt><span class="star">*</span>标题：</dt>
            <dd><input class=" ui-validate" required="true" length="[1,100]" summary="{required:'标题不能为空!',length:'标题不能为空,长度100字以下!'}" type="text" name="title" id="title" style="width:500px" /></dd>
        </dl>

       <dl><dt>Tags：</dt><dd><input class=" ui-validate" length="[0,100]" type="text" name="tags" size="100" style="width:500px" value="${archiveTags}"/>
         &nbsp;<input type="checkbox" style="border:none" name="autotag" title="自动链接Tags" checked="checked"/>自动链接(自动生成tags链接，有利于SEO)
       </dd></dl>
       

       <div>
            <dl style="width:160px;float:left;margin-top:0;">
                <dt>来源：</dt><dd><input class=" ui-validate" length="[0,10]" type="text" name="source" style="width:100px" value="${archiveSource}"/></dd>
             
            </dl>
            <dl style="float:left;margin-top:0;">
                <dt>设置：</dt><dd><input type="checkbox" style="border:none" name="isspecial" title="以特殊的形式显示" ${archiveSpecial}/>推荐
                &nbsp;<input type="checkbox" style="border:none" name="issystem" title="用于系统使用的文档(系统页面不会在搜索和列表中出现)" ${archiveSystem}/>系统
                &nbsp;<input type="checkbox" style="border:none" name="asPage" title="单页，会以单页的URL地址显示" ${archiveAsPage}/>页面
                &nbsp;<input type="checkbox" style="border:none" name="visible" title="只在后台显示，前台均不出现！" ${archiveVisible}/>隐藏
                </dd>
            </dl>
            <div class="clearfix"></div>
        </div>

        

        
        <!-- 960的宽度为标准,一般内容宽度为600左右 -->

        <div id="contentinfo">
        <!-- HTML EDITOR START -->
             <textarea id="editor" name="editor" style="overflow:hidden;width:670px;height:400px;">${editorcontent}</textarea>
        </div>
        <dl><dt>摘要：&nbsp;</dt>
              <dd><textarea class=" ui-validate" length="[0,255]" name="outline" rows="4" cols="5" style="width:620px;font-size:12px;">${archiveOutline}</textarea></dd>
       </dl>

        <dl><dt>缩略图：</dt><dd style="position:relative;height:100px;padding-left:120px;">
                
                    <img src="${thumbnail}" id="thumbnail_img" style="width:80px;height:80px;position:absolute;left:5px;top:0px" />
              

                <input class=" ui-validate" length="[0,100]" type="hidden" name="thumbnail" id="thumbnail" value="${thumbnail}" size="100"/>

                
                 <span id="upload_thumbnail">上传缩略图</span>

                 <input id="ipt_getImg" type="button" value="获取编辑器内图片" onclick="getImg();"/>&nbsp;
                <select id="upimg" name="upimg" style="display: none">
                    <option value="">选择图片</option>
                </select>&nbsp;
                <br />

            

            
        
        </dd></dl>

        <div class="clearfix"></div>

         <dl><dt>别名：</dt><dd><input style="width:360px;" tipin="alias_tipin" value="${archiveAlias}" type="text" id="alias" name="alias" class=" ui-validate" summary="{error:'别名为50位以下的数字,字母,连接符(-),下划线的组合'}"/><a style="margin-left:5px" href="javascript:;">获取别名(自动计算标题的别名)</a>&nbsp;&nbsp;<span id="alias_tipin"></span></dd></dl>
         
        

        <dl><dt>视图：</dt><dd><select name="TemplatePath" id="TemplatePath" class="tb_normal">
            <option value="">一默认一</option>
            ${tpls}
        </select>&nbsp;&nbsp;注：默认则使用栏目（或模块)的视图设置</dd></dl>




    </div>

    
        <!-- 扩展属性 -->
        <div class="extinfo line">

          <div>${extendItemsHtml}</div>
          <div>${extendFieldsHtml}</div>

        </div>

    <div class="submitbar clearfix">
        <a href="javascript:;" class="btn" onclick="return submitForm();">提交</a>
        <a href="javascript:;" class="btn" style="margin-left:5px">重置</a>
    </div>


 </div>
 </div>
</form>

<script type="text/javascript">
    cms.$('title').value = '${archiveTitle}';
    cms.val('TemplatePath', '${archiveTplPath}');

    var editor;
    var thumbID = 'thumbnail', thumbImg = 'thumbnail_img';

    //上传缩略图
    var thumb_upload = cms.upload({
        id: 'upload_thumbnail',
        debug: !true,
        url: '?module=upload&action=uploadimage&for=${thumbPrefix}&upload.id=thumb_upload',
        exts: '*.gif;*.jpg;*.png;*.bmp'
    }, function (path) {
        cms.$('thumbnail').value = path;
        cms.$('thumbnail_img').src = path;
    });

    KindEditor.ready(function (K) {
        editor = K.create('#editor', {
            cssPath: '/framework/common/editor/plugins/code/prettify.css',
            uploadJson: '/framework/common/editor/handler/upload_json.ashx',
            fileManagerJson: '/framework/common/editor/handler/file_manager_json.ashx',
            allowFileManager: true,
            filterMode: false
        });
    });


    function getImg() {
        var content = editor.html();
        var str_img = [];
        var match = null; //三个是都要验证的。因为情况不同
        var reg_html1 = /(?:]*src[\ ]*=[\ ]*(?:['"]?)(\S[^'"\ ]+)(?:['"]?\s[^>]*[>]{1}))/gi;
        var reg_html2 = /(?:]*\s*o\:href=(?:['"]?)(\S[^'"\ ]+)(?:['"]?[^>]+>{1})(?:<\/v\:imagedata>))/gi;
        var reg_html3 = /(?:]*src=(?:['"]?)(\S[^'"\ ]+)(?:['"]?[^>]+)(?:(?:(?:\/>){1})|(?:[>]{1})))/gi;
        while ((match = reg_html1.exec(content)) != null) { //找到每个匹配进行操作。
            str_img.push(match[1]);
        }
        while ((match = reg_html2.exec(content)) != null) { //找到每个匹配进行操作。
            str_img.push(match[1]);
        }
        //这个循环验证会导致多余图片出现
        //while ((match = reg_html3.exec(content)) != null) {//找到每个匹配进行操作。
        //str_img.push(match[1]); 
        //}


        //多张图片赋值给下拉框
        var dpimg = document.getElementById('upimg');
        if (str_img.length > 0) {
            dpimg.style.display = '';
        }

        var seindex = dpimg.selectedIndex;
        dpimg.innerHTML = '<option>一请选择图片一</option>';


        var strs = str_img.toString().split(','); //图片分割     
        for (i = 0; i < strs.length; i++) {
            var oOption = document.createElement("OPTION");
            oOption.innerHTML = "Image" + (i + 1);
            oOption.value = strs[i];
            dpimg.options.add(oOption);
        }

        dpimg.onchange = function () {
            var imgurl = this.options[this.selectedIndex].value;
            if (imgurl != "") {
                cms.$(thumbID).value = imgurl;
                cms.$(thumbImg).src = imgurl;
            }
        };
    }


    function submitForm() {
        if (cms.validator.validate()) {
            cms.val('editor', editor.html());
            if (cms.val('editor') == '') {
                parent.M.alert('请填写内容！');
                return false;
            }

            var data = cms.form.getData();
            cms.xhr.jsonAjax('?module=archive&action=update', data, function (json) {
                if (json.result) {
                    parent.M.alert('操作成功！');
                    Fn.refresh();
                } else {
                    cms.dialog.alert(json.message);
                }
            });
        }
        return false;
    }

    cms.$('alias').onblur = function () {
        if (this.nodeName) {
            var ele = this;
            if (!/^[a-zA-Z0-9_-]{0,50}$/.test(this.value)) {
                cms.validator.setTip(ele, false, 'error', '别名为50位以下的数字,字母,连接符(-),下划线的组合');
            } else {
                cms.validator.removeTip(ele);
            }
        }
    };

    cms.$('alias').nextSibling.onclick = function () {

        var e = this.previousSibling;
        var _title = cms.val('title');
        if (_title == '') {
            cms.validator.setTip(e, false, null, '请先填写标题!');
        } else {
            cms.xhr.post('?', 'module=archive&action=getarchivealias&title=' + encodeURIComponent(_title), function (result) {
                e.value = result.toLowerCase();
                e.onblur();
            }, function () {
                cms.validator.setTip(e, false, null, '获取失败,请重试!');
            });
        }
    };
    /*
    window.onresize = function () {
    var _editor = cms.$('editor');
    var height = document.documentElement.offsetHeight;
    if (height < document.documentElement.clientHeight) {
    height = document.documentElement.clientHeight;
    }

    _editor.style.height = (height - _editor.offsetTop - 30) + 'px';
    _editor.style.width=(document.documentElement.clientWidth-cms.$('side').offsetWidth-30)+'px';
    //cms.$('editorarea').style.height=(document.documentElement.clientHeight-4)+'px';
    };
    window.onresize();
    */



</script>
</body>
</html>
